var collision=false;
with(oSolid){
    //horizontal checking
    if(!collision) {
        //if player on same side as enemy
        if(oPlayer.aboveGround==other.aboveGround){    
            if(rectOverlap(
                other.x+other.dx,other.y, other.x+other.sprite_width+other.dx,other.y+other.sprite_height,
                x,min(y,y+sprite_height),x+sprite_width,max(y,y+sprite_height)
            )){
                other.dx*=-1;
                collision=true; 
            }
        }
        //if player on different side of enemy
        if(oPlayer.aboveGround!=other.aboveGround){
            var y1=y;
            var heightComp=room_height - abs(sprite_height);
            var scale= image_yscale/abs(image_yscale)
            var y2=y- scale*heightComp;
            if(rectOverlap(
                other.x+other.dx,other.y, other.x+other.sprite_width+other.dx,other.y+other.sprite_height,
                x,min(y1,y2),x+sprite_width,max(y1,y2)
            )){
                other.dx*=-1;
                collision=true; 
            }
        }
    }
}

